home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / pardoxed.arc / SEARCH.SC < prev   
Text File  |  1987-08-14  |  5KB  |  180 lines

  1. ;   Search - this routine is gener
  2.  ClearAll
  3.  Clear
  4.  if ISfile("SAVEVARS.sc")
  5.   then
  6.    Play "savevars"
  7.   else
  8.    message "Editor error Savevares not written to disk!!!! - back to edit"
  9.    sleep 1000
  10.   Return
  11.  endif
  12.  
  13.  @2,2 ?? "Loading structure to display.."
  14.  {Tools} {Info} {Structure}    ; routine which will load data types
  15.  select tblname
  16.  lcv = 1                              ; and variables names
  17.  maxn = nrecords("struct")            ; lcv = loop control variable
  18.                                     ; struct is table containing types and vars
  19.  
  20.  Edit "struct"
  21.  Moveto [Field Name]
  22.  
  23.  array datavar[maxn+1]   ; arrays to be loaded with variables
  24.  array datatype[maxn+1]
  25.  
  26.  if maxn <> 0
  27.   then
  28.    while lcv <= maxn
  29.     datavar[lcv] = [Field Name]
  30.     Right
  31.     datatype[lcv] = [Field Type]
  32.     Left
  33.     Down
  34.     lcv = lcv +1
  35.    endwhile ; next record or abort
  36.   else
  37.    ClearAll
  38.    Clear
  39.    Message "Error in struct file!!"
  40.    sleep 750
  41.  endif
  42.  
  43. Do_It!
  44.  
  45. While (TRUE) ;when in edit mode you  can repeat various searchs until satisified
  46.  
  47. Clear
  48.  
  49.     @1,1 ?? "Below is a list of fields that are searched:  "
  50.  
  51. columnwidth = 17
  52. maxdatawidth = 12
  53. maxlinelength = 70
  54. maxitemincol = 17
  55. maxcolumn=1
  56. lcv = 1
  57. column = 0
  58. godown = 4
  59.  
  60. While ((maxcolumn <= maxlinelength) and (lcv <=maxn))
  61.  maxlist = 1
  62.  while ((maxlist <= maxitemincol) and (lcv <=maxn))
  63.   decmal = maxlist + column * maxitemincol
  64.   if len(datavar[lcv]) > maxdatawidth
  65.     then
  66. @ (godown+maxlist),maxcolumn ?? decmal,"} ",substr(datavar[lcv],1,maxdatawidth)
  67.     else
  68.      @ (godown+maxlist),maxcolumn ?? decmal,"} ",datavar[lcv]
  69.   endif
  70.   maxlist = maxlist +1
  71.   lcv = lcv +1
  72.  endwhile
  73.  column = column + 1
  74.  maxlist = 1
  75.  if (maxcolumn <= maxlinelength) ;if put in special ega mode this can be greater
  76.   then                ; for more fields but this will handle 75
  77.    maxcolumn = maxcolumn + columnwidth
  78.   else
  79.    maxcolumn =1000;
  80.  endif
  81. endwhile
  82.  
  83. pick = -1
  84.  
  85. While ((pick < 1) or ( pick > maxn))
  86.  
  87.     @23,1 ?? "Enter integer of field to search:"
  88.     Accept "N" Default 1 to pick
  89.  
  90. endwhile ; protects against PDX overflow since array out of bounds
  91.  
  92.     Message "Chosen field: ",datavar[pick]
  93.  
  94.     @23,1 ?? "Enter string(must be exact):"
  95.     Accept datatype[pick] to thestring
  96.  
  97. @23,1 ?? "                                                                  "
  98.     @23,1 ?? "Last chance to abort search!! Enter ** to abort:"
  99.     Accept "A2" default "go" to srchquit
  100.  
  101.     if srchquit = "**"
  102.       then
  103.        ClearAll
  104.        View tblname
  105.        return
  106.     endif
  107.  
  108.     ; a good data base adminstrator will have a printout of codes to search
  109.     ; or strings that are unique to each record for people who use the editor
  110.     ; and data entry modes often, so entering the exact string is a simple
  111.     ; matter
  112.  
  113.     ; search - this covers many error  conditions one many encounter
  114.  
  115.     ClearAll
  116.     Clear
  117.     @2,2 ?? "Searching... if not found will goto start of file"
  118.     View tblname
  119. ;    FormKey
  120. ;    MOVETO datavar[pick]
  121.  
  122.    right ; number of rec field
  123.    for lcv From 1 to (pick-1)  ;when bug in 1.1 fixed use moveto commented out
  124.     right                     ; above should work accord to regular expression
  125.    endfor                     ; manual - this section code is not necessar
  126.                               ; if user does not change cursor postion in a
  127.     FormKey                   ; a record that has been found, locate is field
  128.     LOCATE thestring          ; specific using active field as key search source
  129.     if retval = True
  130.      then
  131.       peekmore = "N"
  132.       Wait Record
  133.        Message "Enter 'Y' for next occurance or 'N' to stop"
  134.       Until "Y","N","y","n"
  135.       if ((retval = "Y") or (retval = "y"))
  136.        then
  137.         testval = True
  138.         while ( ((retval = "Y") or (retval = "y")) and (testval = True) )
  139.          Recvalue = recno() + 1
  140.          moveto record recvalue
  141.  
  142. ;  moveto datavar[pick]
  143.  
  144.          FormKey
  145.          CtrlHome  ; when moveto gets fixed remove this seciton with
  146.          right     ; replacement statement function
  147.          for lcv from 1 to (pick-1)
  148.           right
  149.          endfor
  150.          FormKey
  151.  
  152.          LOCATE Next thestring
  153.          testval = retval
  154.          if testval = True
  155.           then
  156.            wait record
  157.             message " 'Y' for next item 'N' to return to edit"
  158.            until "Y","N","y","n"
  159.          endif
  160.          if ((nrecords(tblname)=recno()) or  (testval=False))
  161.           then
  162.            testval = False
  163.            Message "End of File encountered/Item not found"
  164.          endif
  165.         endwhile
  166.       endif
  167.     endif
  168. Clear
  169. Message "Search Complete..."
  170. Clear
  171. @2,2 ?? "Would you like another search(Y/N)?:"
  172. accept "A1" to edmore
  173. if ((edmore <> "y") and (edmore <> "Y"))
  174.  then
  175.   return
  176. endif
  177.  
  178. endwhile ; while repeat in edit mode
  179.  
  180.